import 'package:flutter/material.dart';

///drawer
///drawer侧滑栏
class DrawerDemo extends StatefulWidget {
  @override
  _DrawerDemoState createState() => _DrawerDemoState();
}

class _DrawerDemoState extends State<DrawerDemo> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: Text("tabBar"),
      ),
      drawer: MyDrawerWidget(),
      // body: widget.widgets[_index],//不可滑动
      body:Center(
        child:  Text("侧滑试试"),
      ),
    );
  }
}

///drawer侧滑栏
class MyDrawerWidget extends StatefulWidget {
  const MyDrawerWidget({Key? key}) : super(key: key);

  @override
  _MyDrawerWidgetState createState() => _MyDrawerWidgetState();
}

class _MyDrawerWidgetState extends State<MyDrawerWidget> {
  @override
  Widget build(BuildContext context) {
    return Drawer(
      ///清除上方的间距
      child: MediaQuery.removePadding(
        context: context,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Padding(
              padding: EdgeInsets.only(top: 40),
              child: Text("我是侧滑的Widget"),
            )
          ],
        ),
        removeTop: true,
      ),
    );
  }
}
